$(function(){
    var inbtn = 1;
    var url = window.location.href;
    $('#btn_login').click(function(){

        if(inbtn == 0){
            return false;
        }
        inbtn = 0;

        setTimeout(function(){
            inbtn = 1;
        }, 3000);

        var name = $("input[name=name]").val();
        var passwd = $("input[name=passwd]").val();

        if(!name){
            alertMsg('账号名不能为空！');return;
        }

        if(!passwd || passwd.length<6 || passwd.length>20){
            alertMsg('请输入正确的账号密码！');return;
        }

        $.ajax({
            url:url,
            data:{name:name, passwd:passwd},
            dataType: 'json',
            type:'post',
            cache:false,
            success:function(res){
                if(res.status == 1){
                    window.location.href= res.result.url;return;
                }else{
                    alertMsg(res.result.message);return;
                }
            },
            error:function(res){
                alertMsg('请求失败！');return;
            }
        });

    });
});
function alertMsg(msg){
    $('#imMsgBoxMsg').html(msg);
    $('#imMsgBox,#overlayDiv').show();

}
function alertClose(){
    $('#imMsgBox,#overlayDiv').hide();
}